﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_GetStyleDescription_ByFlow_V2]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_GetStyleDescription_ByFlow_V2];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_GetStyleDescription_ByFlow_V2]
    @FlowID int,
    @JudgedOnly bit = 1  -- whether to only retrieve fields to be evaluated.
AS
BEGIN
SET NOCOUNT ON;

DECLARE @StyleID int;
SET @StyleID = 0;

-- Get the id of the referenced style
SELECT @StyleID = Style_ID FROM dbo.UDS_Flow WHERE Flow_ID = @FlowID;
IF ( @@ROWCOUNT = 1 )
BEGIN
    IF @JudgedOnly = 0
        SELECT @StyleID as Style_ID, * 
            FROM dbo.uds_flow_style_description
            WHERE style_ID = @StyleID
            ORDER BY [position];

    ELSE
        SELECT @StyleID as Style_ID, * 
            FROM dbo.uds_flow_style_description
            WHERE Style_ID = @StyleID and Judged = 1
            ORDER BY [position];
END

END
GO